package com.example.boot1.singleton;

/**
 * @author Create By Liuqz
 * @date 2020/2/1 17:44
 */
public class doubleCheck {

    //使用volatile关键字进行修饰目的是防止指令重排
    private volatile static  doubleCheck instance;

    public doubleCheck() {
    }

    public static doubleCheck getInstance() {
        if (null == instance) {
            synchronized (doubleCheck.class) {
                if (null == instance) {
                    instance = new doubleCheck();
                }
            }
        }
        return instance;
    }
}
